#ifndef HUMITURE_H
#define HUMITURE_H

#include <esp_log.h>
#include "driver/uart.h"

class HumitureManager {
public:
    HumitureManager();
    ~HumitureManager();

    // 设置温度阈值
    void SetTemperatureThreshold(float threshold)
    {
        m_TemperatureThreshold = threshold;
    }
    // 获取温度阈值
    float GetTemperatureThreshold()
    {
        return m_TemperatureThreshold;
    }

    // 设置湿度阈值
    void SetHumidityThreshold(float threshold)
    {
        m_HumidityThreshold = threshold;
    }
    // 获取湿度阈值
    float GetHumidityThreshold()
    {
        return m_HumidityThreshold;
    }

    // 获取当前温度值H
    float GetCurrentTemperatureData()
    {
        return m_CurrentTemperatureData;
    }

    // 获取当前湿度值
    float GetCurrenthumidityData()
    {
        return m_CurrenthumidityData;
    }

    // 轮询计时器
    void OnHumitureManagerTimer();

    // 读取温湿度传感器数据
    void readHumitureData();
    void parse_sensor_data(const char* response);
    void uart_send_data(const char* data);

public:
    static void uart_event_task(void* pvParams) {  // 必须声明为static
        HumitureManager* instance = static_cast<HumitureManager*>(pvParams);
        instance->process_uart_events();  // 调用实际处理的成员函数
    }

    void process_uart_events();

private:
    float m_CurrentTemperatureData = 0.0f; // 当前温度值
    float m_CurrenthumidityData = 0.0f;    // 当前湿度值
    float m_TemperatureThreshold = 20.0f;  // 温度阈值
    float m_HumidityThreshold = 30.0f;     // 湿度阈值
};
#endif